<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>医院预约系统实体关系图</title>
    <script src="https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.css">
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #f5f5f5;
            margin: 0;
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .container {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            padding: 20px;
            margin-bottom: 20px;
            max-width: 1200px;
            width: 100%;
        }
        h1 {
            color: #2c3e50;
            text-align: center;
            margin-bottom: 30px;
        }
        .mermaid {
            margin: 30px 0;
            display: flex;
            justify-content: center;
        }
        .mermaid svg {
            max-width: 100%;
            height: auto;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>医院预约系统实体关系图</h1>
        <div class="mermaid">
graph TD
    %% 实体定义
    User[用户]
    Doctor[医生]
    Department[科室]
    Schedule[排班]
    Appointment[预约]
    HealthCheck[健康打卡]
    Post[帖子]
    Comment[评论]
    Favorite[收藏]

    %% 关系定义
    UserDoctorRel{是}
    DoctorDeptRel{属于}
    DoctorScheduleRel{排班}
    DoctorAppointmentRel{接受}
    UserAppointmentRel{预约}
    UserHealthCheckRel{打卡}
    UserPostRel{发布}
    UserCommentRel{评论}
    UserFavoriteRel{收藏}
    PostCommentRel{包含}
    PostFavoriteRel{被收藏}

    %% 连接实体和关系（分别标注1和N）
    User ---|1| UserDoctorRel
    UserDoctorRel ---|1| Doctor
    User ---|1| UserAppointmentRel
    UserAppointmentRel ---|N| Appointment
    User ---|1| UserHealthCheckRel
    UserHealthCheckRel ---|N| HealthCheck
    User ---|1| UserPostRel
    UserPostRel ---|N| Post
    User ---|1| UserCommentRel
    UserCommentRel ---|N| Comment
    User ---|1| UserFavoriteRel
    UserFavoriteRel ---|N| Favorite

    Doctor ---|N| DoctorDeptRel
    DoctorDeptRel ---|1| Department
    Doctor ---|1| DoctorScheduleRel
    DoctorScheduleRel ---|N| Schedule
    Doctor ---|1| DoctorAppointmentRel
    DoctorAppointmentRel ---|N| Appointment

    Department ---|1| DoctorDeptRel
    Department ---|1| DoctorScheduleRel

    Post ---|1| PostCommentRel
    PostCommentRel ---|N| Comment
    Post ---|1| PostFavoriteRel
    PostFavoriteRel ---|N| Favorite
        </div>
    </div>
    <script>
        mermaid.initialize({
            startOnLoad: true,
            securityLevel: 'loose',
            theme: 'default'
        });
    </script>
</body>
</html> 